package xlp.com.practicedemo

import android.app.KeyguardManager
import android.content.Context
import android.os.Build
import android.os.Bundle
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat
import android.support.v7.app.AppCompatActivity

class FingerPrintActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_finger_print)
        //1.添加权限

        //2.获取manager对象
        val fpm = FingerprintManagerCompat.from(this)//v4兼容包

        //3.判断硬件是否支持
        if(!fpm.isHardwareDetected){
            //提示用户硬件不支持
        }

        //4.判断当前设备是否在保护中(谷歌要求使用指纹识别的前提是设备有屏幕锁)
        val keyguardManager  = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
        if (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    keyguardManager.isKeyguardSecure
                } else {
                    false
                }){

        }

        //5.判断系统中是否有注册的指纹
        if(!fpm.hasEnrolledFingerprints()){
            //提示用户去注册指纹
        }

        //6.初始化CryptoObject加密类对象
    }

    class CryptoObjectHelper{

    }
}
